package edu.ccut.saturn.studio.database.ui;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Image;


import edu.ccut.saturn.studio.Activator;
import edu.ccut.saturn.studio.Images;
import edu.ccut.saturn.studio.database.model.DBConnection;
import edu.ccut.saturn.studio.database.model.DBConnectionProvider;

/**
 * 
 * @author Bai Yucheng 2007-12-8
 * 
 */
public class ViewerDBConContentProvider implements ITableLabelProvider,
		IStructuredContentProvider {

	public ViewerDBConContentProvider() {
	}

	public void inputChanged(Viewer viewer, Object obj, Object obj1) {
	}

	public void dispose() {
	}

	public Object[] getElements(Object obj) {
		return DBConnectionProvider.getInstance().getAllDBConnections()
				.toArray();
	}

	public Image getColumnImage(Object obj, int i) {
		if ((obj instanceof DBConnection) && i == 0) {
			return Activator.getImage(Images.DATABASE_CONNECTION);
		}
		
		return null;
	}

	public String getColumnText(Object obj, int i) {
		return obj.toString();
	}

	public void addListener(ILabelProviderListener ilabelproviderlistener) {
	}

	public boolean isLabelProperty(Object obj, String s) {
		return false;
	}

	public void removeListener(ILabelProviderListener ilabelproviderlistener) {
	}
}